package com.c1.client.dialog.input.button;

import com.c1.client.dialog.BaseButton;
import com.c1.client.dialog.input.InputDialog;
import com.c1.client.menu.MenuManager;
import com.s.S;
import com.s.core.root.Ad;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

public class InputGoButton extends BaseButton {
    private static final String CONFIRM_TEXT = "确认";

    @Override
    public String getText() {
        return CONFIRM_TEXT;
    }

    @Override
    public void process() {
        String content = InputDialog.me().getTextAreaText();
        boolean isExcludeMode = InputDialog.me().isExcludeMode();
        boolean isExcludeCanNotBuy = InputDialog.me().isExcludeCanNotBuy();
        String date = InputDialog.me().getDateText();
        date = StringUtils.isEmpty(date) ? Ad.me().getDateList().get(0) : date;
        List<String> codes = S.serverData.codes(content, date, isExcludeMode, isExcludeCanNotBuy);
        if (CollectionUtils.isEmpty(codes)) {
            return;
        }
        InputDialog.me().setVisible(false);
        MenuManager.me().showStocksByCodes(codes, date);
    }
}
